package com.ming.yygh.oss.controller;

import com.ming.yygh.common.result.Result;
import com.ming.yygh.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author Light
 * @date 2021/12/20 15:13
 */
@Api(tags = "oss相关接口")
@RestController
@RequestMapping("api/oss/file")
public class FileApiConteoller {

    @Resource
    private FileService fileService;

    // 上传文件到阿里云oss
    @ApiOperation(value = "上传图片")
    @PostMapping("/fileUpload")
    public Result<String> fileUpload(MultipartFile file) {
        // 获取上传的文件
        String fileUrl = fileService.upload(file);
        return Result.ok(fileUrl);
    }
}
